package util.AST.Comando.Simples;

import java.util.ArrayList;

import util.AST.Expressao.Expressao;
import util.AST.Comando.Simples.ComandoSimples;

public class ComandoWhile extends ComandoSimples {

	private Expressao condicao;
	private ArrayList<ComandoSimples> ComandoSimples;
	
	public ComandoWhile(Expressao condicao, ArrayList<ComandoSimples> ComandoSimples) {
		this.condicao = condicao;
		this.ComandoSimples = ComandoSimples;
	}

	@Override
	public String toString(int level) {
		int nextLevel = level+5;
		StringBuffer str = new StringBuffer();
		str.append("WHIL\n");
		str.append(super.getSpaces(nextLevel) + "|-COND\n");
		str.append(super.getSpaces(nextLevel+5) + "|-");
		if ( this.condicao != null ) {
			str.append(this.condicao.toString(nextLevel+5));
		}
		str.append(super.getSpaces(nextLevel) + "|-WLST\n");
		if ( this.ComandoSimples != null ) {
			for (ComandoSimples ComandoSimples : this.ComandoSimples) {
				str.append(super.getSpaces(nextLevel+5) + "|-");			
				str.append(ComandoSimples.toString(nextLevel+5));
			}
		}
		return str.toString();
	}

	//get e set
	public Expressao getCondicao() {
		return condicao;
	}

	public void setCondicao(Expressao condicao) {
		this.condicao = condicao;
	}

	public ArrayList<ComandoSimples> getComandoSimples() {
		return ComandoSimples;
	}

	public void setComandoSimples(ArrayList<ComandoSimples> comandoSimples) {
		ComandoSimples = comandoSimples;
	}
	
}
